#include <stdio.h>

int z;

int add(int x, int y)
{
	return (x + y + z);
}

int main(void)
{
	int a = 5, b = 6;
	
	z = 7;
	add(a, b);

	return 0;
}

#if 0

/*
 * intel
 */
0000000000001129 <add>:
    1129:	f3 0f 1e fa          	endbr64 
    112d:	55                   	push   %rbp
    112e:	48 89 e5             	mov    %rsp,%rbp
    1131:	89 7d fc             	mov    %edi,-0x4(%rbp)	// (rbp-0x4)=edi
    1134:	89 75 f8             	mov    %esi,-0x8(%rbp)	// (rbp-0x8)=esi
    1137:	8b 55 fc             	mov    -0x4(%rbp),%edx	// edx=(rbp-0x4)
    113a:	8b 45 f8             	mov    -0x8(%rbp),%eax	// eax=(rbp-0x8)
    113d:	01 c2                	add    %eax,%edx	// edx+=eax
    113f:	8b 05 cf 2e 00 00    	mov    0x2ecf(%rip),%eax        # 4014 <z>	eax=rip+0x2ecf
    1145:	01 d0                	add    %edx,%eax	// eax=edx
    1147:	5d                   	pop    %rbp
    1148:	c3                   	retq   

0000000000001149 <main>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp
    114e:	48 89 e5             	mov    %rsp,%rbp
    1151:	48 83 ec 10          	sub    $0x10,%rsp
    1155:	c7 45 f8 05 00 00 00 	movl   $0x5,-0x8(%rbp)	// (rbp-0x8)=5
    115c:	c7 45 fc 06 00 00 00 	movl   $0x6,-0x4(%rbp)	// (rbp-0x4)=6
    1163:	c7 05 a7 2e 00 00 07 	movl   $0x7,0x2ea7(%rip)        # 4014 <z>	rip+0x2ea7=0x7
    116a:	00 00 00 
    116d:	8b 55 fc             	mov    -0x4(%rbp),%edx	// edx=6
    1170:	8b 45 f8             	mov    -0x8(%rbp),%eax	// eax=5
    1173:	89 d6                	mov    %edx,%esi	// esi=6
    1175:	89 c7                	mov    %eax,%edi	// edi=5
    1177:	e8 ad ff ff ff       	callq  1129 <add>	// add(edi, esi)
    117c:	b8 00 00 00 00       	mov    $0x0,%eax
    1181:	c9                   	leaveq 
    1182:	c3                   	retq   
    1183:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    118a:	00 00 00 
    118d:	0f 1f 00             	nopl   (%rax)

/*
 * arm
 */
000000000040051c <add>:
  40051c:	d10043ff 	sub	sp, sp, #0x10
  400520:	b9000fe0 	str	w0, [sp, #12]	// [sp+12]=w0
  400524:	b9000be1 	str	w1, [sp, #8]	// [sp+8]=w1
  400528:	b9400fe1 	ldr	w1, [sp, #12]	// w1=[sp+12]
  40052c:	b9400be0 	ldr	w0, [sp, #8]	// w0[sp+8]
  400530:	0b000021 	add	w1, w1, w0	// w1=w1+w0
  400534:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400538:	9100b000 	add	x0, x0, #0x2c	// x0=41102c
  40053c:	b9400000 	ldr	w0, [x0]	// w0=[x0]
  400540:	0b000020 	add	w0, w1, w0	// w0=w1+w0
  400544:	910043ff 	add	sp, sp, #0x10
  400548:	d65f03c0 	ret

000000000040054c <main>:
  40054c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400550:	910003fd 	mov	x29, sp
  400554:	528000a0 	mov	w0, #0x5                   	// #5
  400558:	b9001fa0 	str	w0, [x29, #28]	// [x29+28]=5
  40055c:	528000c0 	mov	w0, #0x6                   	// #6
  400560:	b9001ba0 	str	w0, [x29, #24]	// [x29+24]=6
  400564:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400568:	9100b000 	add	x0, x0, #0x2c	// x0=41102c
  40056c:	528000e1 	mov	w1, #0x7                   	// #7
  400570:	b9000001 	str	w1, [x0]	// [x0]=w1
  400574:	b9401ba1 	ldr	w1, [x29, #24]	// w1=[x29+24]
  400578:	b9401fa0 	ldr	w0, [x29, #28]	// w0=[x29+28]
  40057c:	97ffffe8 	bl	40051c <add>
  400580:	52800000 	mov	w0, #0x0                   	// #0
  400584:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400588:	d65f03c0 	ret
  40058c:	00000000 	.inst	0x00000000 ; undefined

#endif
